package cn.xy.ymcc.web.controller;

import cn.xy.ymcc.dto.RegisterDto;
import cn.xy.ymcc.result.JSONResult;
import cn.xy.ymcc.service.IVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 抽取接口工具类
 * 图形验证码
 */
@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {
    @Autowired
   private IVerifyCodeService verifyCodeService;

    /**
     * 图形验证码
     *
     * @param key
     * @return
     */
    @GetMapping("/imageCode/{imageCodeKey}")
    public JSONResult imageCode(@PathVariable("imageCodeKey") String key) {

            String base64Str = verifyCodeService.imageCode(key);
            return JSONResult.success(base64Str);

    }

    /**
     * 短信验证码
     * @param
     * @return
     */
    @PostMapping("/sendSmsCode")
    public JSONResult sendSmsCode(@RequestBody RegisterDto dto) {

        verifyCodeService.smsCode(dto);
        return JSONResult.success();

    }
}